#ifndef SMBMANAGER_H
#define SMBMANAGER_H

#include <QVector>
#include <QString>
#include <QMap>

#include "JNIManager.h"
#include "dbHelper.h"
#ifdef Q_OS_ANDROID

// 网络连接ip管理
class SMBManager
{
private:

    SMBManager();

public:

    struct ConnectInfo{
        QString ip;
        QString usr;
        QString pwd;
        ConnectInfo(){
            ip = "";
            usr = "";
            pwd = "";
        }
        ConnectInfo(QString ip, QString usr, QString pwd){
            this->ip = ip;
            this->usr = usr;
            this->pwd = pwd;
        }
    };

    static SMBManager& I();

    // 连接管理
    QStringList     getIpList();
    bool            loadConnection();       // 加载数据库连接
    bool            addConnection(QString ip, QString usr="", QString psw = "");
    bool            delConnection(QString ip);

    // 文件操作
    QStringList     getFileList(QString ip, QString path);
    bool            uploadFile(QString SMBPath, QString localPath);
    bool            uploadFile(QString ip, QString remotePath, QString localPath);
    bool            downloadFile(QString SMBPath, QString localPath);
    bool            downloadFile(QString ip, QString remotePath, QString localPath);

    // 路径解析 格式 SMB://192.168.1.183/Folder/file.txt
    QString     createSMBPath(QString ip, QString path);
    void        splitSMBPath(QString SMBPath, QString& ip, QString& path);

    // SMB路径转本地缓存路径
    static QString  SMB2Local(QString SMBPath);
    static bool     isSMBPath(QString SMBPath);


private:
    QMap<QString, ConnectInfo>   _connectMap;  // <ip, 连接信息>

};

#endif // SMBMANAGER_H
#endif
